// https://nuxt.com/docs/api/configuration/nuxt-config
import Components from 'unplugin-vue-components/vite'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
export default defineNuxtConfig({
    devtools: {enabled: true},
    // Nuxt应用程序配置
    app: {
        head: {
            // 动态标题模板，其中`%s`会被标题替换
            titleTemplate: '%s - 自由社区',
            // 全局引入public下的css样式
            link: [
                // { rel: 'stylesheet', href: '/fonts/iconfont.css' },
                // { rel: 'stylesheet', href: '/css/animate.css' }
            ]
        }
    },
    // 全局引入assets下的css样式
    css: [
        '@/assets/css/main.css',
    ],


    modules: [
        'nuxt-windicss',
        [
            '@pinia/nuxt',
            {
                autoImports: [
                    // 自动引入 `defineStore()`
                    'defineStore',
                ]
            }
        ],
        '@pinia-plugin-persistedstate/nuxt',
    ],

    // 引入Naive-ui
    build: {
        transpile:
            process.env.NODE_ENV === 'production'
                ? [
                    'naive-ui',
                    'vueuc',
                    '@css-render/vue3-ssr',
                    '@juggle/resize-observer'
                ]
                : ['@juggle/resize-observer']
    },
    vite: {
        plugins: [
            Components({
                resolvers: [NaiveUiResolver()] // 全自动按需引入naive-ui组件
            })
        ],
        optimizeDeps: {
            include:
                process.env.NODE_ENV === 'development'
                    ? ['naive-ui', 'vueuc', 'date-fns-tz/formatInTimeZone']
                    : []
        }
    },
    imports: {
        // 全局导入接口
        dirs: ["apis"],
    }
})
